# -- coding: utf-8 -- 
# Name: app

from flask import Flask,session
from datetime import timedelta
import os
app = Flask(__name__)
app.config['SECRET_KEY'] = os.urandom(24)
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
@app.route('/')
def set_session():
    session['username'] = 'zhangsan'
    session.permanent = True
    return 'session set seccussful'

@app.route('/get_session')
def get_session():
    username = session.get('username')
    return username or 'session is null'

@app.route('/del_session')
def del_session():
    session.pop('username')
    return 'delete sessions'

if __name__ == '__main__':
    app.run()


# import requests
# def verify(self):
#     url = self.result['target'] + '/'
#     cookies = requests.get(url).headers['Set-Cookie']
#     headers = {
#         'Cookie': cookies
#     }
#     try:
#         url = self.result['target'] + '/post'
#         data = 'user=admin&pass=admin'
#         new_cookie = requests.post(url,headers,data=data,timeout=10,verify=False).headers['Set-Cookie']
#         if cookies == new_cookie:
#             print "success"
#     except:
#         pass

